package com.niit.az;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class EvaluationIn extends AppCompatActivity {

    private EditText etEvaluationName;
    private TextView tvEvaluationResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_evaluation_in);


        etEvaluationName=findViewById(R.id.et_evaluation_name);
        tvEvaluationResult=findViewById(R.id.jieguo);

        findViewById(R.id.btn_evaluation_in).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(TextUtils.isEmpty(etEvaluationName.getText().toString())){
                    Toast.makeText(EvaluationIn.this,"输入姓名不能为空",
                            Toast.LENGTH_LONG).show();
                    return;
                }
                Intent myIntent=new Intent(EvaluationIn.this,EvaluationOut.class);
                myIntent.putExtra("name",etEvaluationName.getText().toString().trim());
                //  startActivity(myIntent);
                startActivityForResult(myIntent,1000);
            }
        });

        findViewById(R.id.btn_out).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==1000 && resultCode==1001){
            String result=data.getStringExtra("result");
            tvEvaluationResult.setText("评估结果："+ result+",感谢您的反馈！");
        }
    }


}
